//
//  JDCityShareTableViewCell.swift
//  DragonWallet
//
//  Created by volantPig on 2024/5/7.
//

import UIKit

class JDCityShareTableViewCell: UITableViewCell {

    var containerView: UIView?
    
    var shareImgV: UIImageView?
    var middleLine: UIView?
    var shareTitleLabel: UILabel?
    var createTime: UILabel?
    var shareStoreTitleLabel: UILabel?
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor = color("#F5F6F8")
        self.setupUIElements()
    }
    
    func setupUIElements() {
        
        self.containerView = UIView()
        self.contentView.addSubview(self.containerView!)
        self.containerView?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.contentView)
            make.bottom.equalTo(self.contentView).offset(-10)
        })
        self.containerView?.backgroundColor = .white
        self.containerView?.layer.cornerRadius = 8
        
//        var shareImgV: UIImageView?
//        var shareTitleLabel: UILabel?
//        var createTime: UILabel?
//        var shareStoreTitleLabel: UILabel?
        self.shareImgV = UIImageView()
        self.containerView?.addSubview(self.shareImgV!)
        self.shareImgV?.snp.makeConstraints({ make in
            make.top.equalTo(self.containerView!).offset(15)
            make.left.equalTo(self.containerView!).offset(12)
            make.size.equalTo(CGSize(width: 74, height: 74))
        })
        self.shareImgV?.backgroundColor = .yellow

        self.middleLine = UIView()
        self.containerView?.addSubview(self.middleLine!)
        self.middleLine?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerView!).offset(12)
            make.right.equalTo(self.containerView!).offset(-12)
            make.top.equalTo(self.shareImgV!.snp.bottom).offset(15)
            make.height.equalTo(1)
        })
        self.middleLine?.backgroundColor = color("#F5F6F8")
        
        self.shareStoreTitleLabel = UILabel()
        self.containerView?.addSubview(self.shareStoreTitleLabel!)
        self.shareStoreTitleLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerView!).offset(12)
            make.top.equalTo(self.middleLine!.snp.bottom)
            make.height.equalTo(50)
            make.bottom.equalTo(self.containerView!)
        })
        self.shareStoreTitleLabel?.text = "百香园水果超市"
        self.shareStoreTitleLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"), numberOfLines: 0)
        
        //        var shareTitleLabel: UILabel?
        //        var createTime: UILabel?
        self.shareTitleLabel = UILabel()
        self.containerView?.addSubview(self.shareTitleLabel!)
        self.shareTitleLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.shareImgV!.snp.right).offset(15)
            make.top.equalTo(self.shareImgV!)
            make.right.equalTo(self.containerView!).offset(-12)
        })
        self.shareTitleLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .regular), textColor: color("#333333"), numberOfLines: 2)
        self.shareTitleLabel?.text = "分享包描述分享包描述分享包描述分享包描述分享包描述分享包描述分享包描述分享包描述"
        
        self.createTime = UILabel()
        self.containerView?.addSubview(self.createTime!)
        self.createTime?.snp.makeConstraints({ make in
            make.left.equalTo(self.shareTitleLabel!)
            make.bottom.equalTo(self.shareImgV!).offset(-7)
        })
        self.createTime?.text = "2024/10/10"
        self.createTime?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 12, weight: .regular), textColor: color("#333333"), numberOfLines: 0)
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
